package com.hkbigdata.sybx.service;

import com.hkbigdata.sybx.mapper.UserProfileMapper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author yangjing
 * @creat 2025-06-04-14:16
 * @email 3010335359@qq.com
 */

@Service
public class UserNameService {

    private final UserProfileMapper userProfileMapper;

    public UserNameService(UserProfileMapper userProfileMapper) {
        this.userProfileMapper = userProfileMapper;
    }

    /**
     * 根据用户ID获取用户名
     * @param userId 用户ID
     * @return 包含用户名的结果Map
     */
    public Map<String, Object> getUserNameByUserId(String userId) {
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> userData = userProfileMapper.getUserNameById(userId);

        if (userData != null && !userData.isEmpty()) {
            result.put("code", 200);
            result.put("message", "获取成功");
            result.put("data", userData);
        } else {
            result.put("code", 404);
            result.put("message", "用户不存在");
        }
        return result;
    }

}